#ifndef ITEM_DATABASE_H
#define ITEM_DATABASE_H

#include <map>
#include <string>

#include "boost_filesystem.h"
#include "boost/noncopyable.hpp"

#include "ItemData.h"

class Item;

// Based off http://www.gamedev.net/reference/articles/article2163.asp.
class ItemDatabase : public boost::noncopyable
{
public:
	static void initialise(std::string fileName);
    static void cleanUp();

    static ItemDatabase& get();

    const ItemData& getData(int item_id);
    const ItemData& getData(const Item& item);

    void addItemData(const ItemData& ItemData, int id);
    void save(std::string saveName) const;
private:
	ItemDatabase();

    bool readFile(std::string saveName);
    void writeFile(std::string saveName) const;

	static ItemDatabase instance;
	static bool initialised;

    typedef std::map<int, ItemData> idata_map;
    typedef idata_map::iterator idata_it;
    idata_map entries;
};

#define GET_ITEM_DATA(item) ItemDatabase::get().getData(item)

#endif